package com.tyd.cams;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.tyd.cams.Adapter.KaoqinListAdapter;
import com.tyd.cams.entity.KaoQinJilubean;
import com.tyd.cams.entity.KaoQinbean;
import com.tyd.cams.entity.StuCjbean;
import com.tyd.cams.entity.User;
import com.tyd.cams.utils.SPUtils;
import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xui.widget.dialog.strategy.IDialogStrategy;
import com.xuexiang.xui.widget.dialog.strategy.impl.MaterialDialogStrategy;
import com.xuexiang.xui.widget.toast.XToast;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.List;

import okhttp3.Call;

import static com.xuexiang.xui.XUI.getContext;

public class KaoqinjiluActivity extends AppCompatActivity {
ListView listView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_kaoqinjilu);

        getkaoqin();
    }
    private void getkaoqin() {
        new Thread(() -> OkHttpUtils.post()
                .url(SPUtils.getIP() + "/kaoqin/getInfo")
                .addHeader("Authorization", SPUtils.getToken())
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        XToast.normal(KaoqinjiluActivity.this, "查询考勤超时").show();
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.i("获取的返回信息", response);
                        Gson son = new Gson();
                        List<KaoQinJilubean> kaoQinJilubeanList = son.fromJson(response, new TypeToken<List<KaoQinJilubean>>() {
                        }.getType());
                        listView=findViewById(R.id.list_kaoqin);
                        KaoqinListAdapter adapter = new KaoqinListAdapter(KaoqinjiluActivity.this, kaoQinJilubeanList);
                        listView.setAdapter(adapter);
                        Log.i("考勤记录",kaoQinJilubeanList.toString());
                    }
                })).start();
    }
}